package org.example.spring.ioc.config;

import org.example.spring.ioc.bean.person;
import org.example.spring.ioc.condition.MacCondition;
import org.example.spring.ioc.condition.WindowsCondition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PersonConfiguration {
    //场景：判断电脑操作系统是windows还是mac
    //windows:容器中放bill
    //mac：容器中放lucy

    @Conditional(WindowsCondition.class)
    @Bean
    public person bill(){
        person person = new person();
        person.setName("Bill Gates");
        person.setAge(50);
        person.setGender("男");
        return person;
    }

    @Conditional(MacCondition.class)
    @Bean
    public person lucy(){
        person person = new person();
        person.setName("Lucy");
        person.setAge(18);
        person.setGender("女");
        return person;
    }




    //3.给容器中注册一个自己的组件；方法名就是组件的名字
    @Bean("haha")
    public person person(){
        person person = new person();
        person.setName("张三");
        person.setAge(18);
        person.setGender("男");
        return person;
    }

    @Bean
    public person person2(){
        person person = new person();
        person.setName("李四");
        person.setAge(18);
        person.setGender("男");
        return person;
    }
}
